setwd("/Users/ling-jwe/Documents/R/BOGGLE")
crit=0
# The first two commands make tables with combinations of two letters at word onsets and offsets:
onsets2=sapply(outer(1:26,1:26,function(r,c){paste(letters[r],letters[c],sep="")}),
function(x){sum(regexpr(paste("^",x,sep=""),dutch)>0)}) # if the combination does not occur, the sum is zero.
offsets2=sapply(outer(1:26,1:26,function(r,c){paste(letters[r],letters[c],sep="")}),
function(x){sum(regexpr(paste(x,"$",sep=""),dutch)>0)})
# The next two commands make tables with combinations of each letter of the alphabet and the
# combinations that exist on word boundaries. These take a while.
offsets3=sapply(
outer(1:26,1:length(offsets2[offsets2>0]),function(r,c){paste(letters[r],names(offsets2[offsets2>0])[c],sep="")}), # 347 offsets
function(x){sum(regexpr(paste(x,"$",sep=""),dutch)>0)})
onsets3=sapply(
outer(1:26,1:length(onsets2[onsets2>0]),function(r,c){paste(names(onsets2[onsets2>0])[c],letters[r],sep="")}), # 305 onsets
function(x){sum(regexpr(paste("^",x,sep=""),dutch)>0)})
# The following commands aggregate the consonants that are not allowed in combination with each onset or offset
onsets2.res=sapply(letters[1:26],function(x){paste(substr(names(onsets2[which(onsets2==0&substr(names(onsets2),1,1)==x)]),2,2),collapse="")})
offsets2.res=sapply(letters[1:26],function(x){paste(substr(names(offsets2[which(offsets2==0&substr(names(offsets2),2,2)==x)]),1,1),collapse="")})
onsets3.res=sapply(names(onsets2[onsets2>0]),function(x){paste(substr(names(onsets3[which(onsets3==0&substr(names(onsets3),1,2)==x)]),3,3),collapse="")})
offsets3.res=sapply(names(offsets2[offsets2>0]),function(x){paste(substr(names(offsets3[which(offsets3==0&substr(names(offsets3),2,3)==x)]),1,1),collapse="")})
#
write.table(
c(paste("^",names(c(onsets2.res,onsets3.res)),"[",c(onsets2.res,onsets3.res),"]",sep=""),
paste("[",c(offsets2.res,offsets3.res),"]",names(c(offsets2.res,offsets3.res)),"$",sep="")),
file="myresults.txt",row.names=F,col.names=F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.